package Timer;

public class Time {
    private int hour;
    private int minute;
    private int second;

    Time(int aHour, int aMinute, int aSecond) {
        this.hour = aHour;
        this.minute = aMinute;
        this.second = aSecond;
    }

    Time() {

    }

    public void setTime(int aHour, int aMinute, int aSecond) {
        if (aHour >= 0 && aHour <= 24)
            this.hour = aHour;
        if (aMinute >= 0 && aMinute <= 59)
            this.minute = aMinute;
        if (aSecond >= 0 && aSecond <= 59)
            this.second = aSecond;
    }

    public String toString() {
        return this.hour + ":" + this.minute + ":" + this.second;
    }

    public void nextSecond() {
        this.second++;
        if (this.second == 60) {
            this.second = 0;
            this.minute++;
            if (this.minute == 60) {
                this.minute = 0;
                this.hour++;
                if (this.hour == 24) {
                    this.hour = 0;
                }
            }
        }
    }
}
